//
//  HMAdviceViewController.m
//  G05爱鲜蜂
//
//  Created by 小灰灰 on 16/10/16.
//  Copyright © 2016年 何源. All rights reserved.
//

#import "HMAdviceViewController.h"

@interface HMAdviceViewController ()
@property(nonatomic,weak)UILabel *remindLabel;
@property(nonatomic,weak)UITextView *adviceTextView;
@end

@implementation HMAdviceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGBColor(224, 224, 224);
    [self setUI];
}
-(void)setUI{
    self.navigationItem.title = @"意见反馈";
    //提示文字
    UILabel *headLabel = [[UILabel alloc] init];
    headLabel.text = @"你的批评和建议能帮助我们更好的完善产品，请留下您的宝贵意见!";
    headLabel.numberOfLines = 0;
    headLabel.textColor = [UIColor blackColor];
    [headLabel sizeToFit];
    headLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:headLabel];
    [headLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.view).offset(15);
        make.trailing.equalTo(self.view).offset(-15);
        make.top.equalTo(self.view).offset(20);
    }];
    //意见输入框
    UITextView *adviceTextView = [[UITextView alloc] init];
    _adviceTextView = adviceTextView;
    adviceTextView.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:adviceTextView];
    [adviceTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headLabel.mas_bottom).offset(20);
        make.leading.equalTo(self.view).offset(15);
        make.centerX.equalTo(self.view);
        make.height.equalTo(self.view).multipliedBy(0.2);
    }];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeLabelText) name:UITextViewTextDidChangeNotification object:nil];
    //默认显示文字
    UILabel *remindLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 6, 300, 20)];
    _remindLabel = remindLabel;
    remindLabel.font = [UIFont systemFontOfSize:14];
    remindLabel.text = @"请输入您的宝贵意见（300字以内)";
    remindLabel.textColor = [UIColor grayColor];
    [adviceTextView addSubview:remindLabel];
    
    //发送按钮
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"发送" style:UIBarButtonItemStyleDone target:self action:@selector(sendBtnClick:)];
    
}

-(void)changeLabelText{
    if(self.adviceTextView.text.length != 0){
        self.remindLabel.text = @"";
    }
    else{
       self.remindLabel.text =@"请输入您的宝贵意见（300字以内)";
    }
    
}
//发送按钮
-(void)sendBtnClick:btn{
    if(self.adviceTextView.text.length){
    //发送成功
        NSLog(@"发送成功");
    //返回上层控制器
        
    //恭喜动画
    }
    else{
      //没有文字
        
    }
}









@end
